﻿using System;
using System.Drawing;
using System.Timers;

using DC2010.Objects;
using DC2010.Objects.Base;
using DC2010.Objects.Data;

namespace DC2010.Effects
{
    public class I_Delay_Effect : EffectLogic
    {
		public bool stilldelaying = true;
		
        public I_Delay_Effect(EffectData ed):base(ed)
        {
            ShortName = "Delay in seconds";
            LongName = "This effect creates a delay in seconds";
            Id = "I_DELAY_EFFECT";
            EffectType = EffectType.Instant;
        }

        public override void Instant(BaseObject aInvoker, BaseObject aTarget)
        {
			int delay = Data.Params.Find(A => A.Key == "DELAY").Value.ToInt();
			
		    Timer t = new Timer(delay*1000);
            t.Elapsed += delegate(object sender, ElapsedEventArgs e)
            {
                stilldelaying = false;
            };
            t.Start();

            while (stilldelaying)
            {
                ;
            }	

            base.Instant(aInvoker, aTarget);
        }
    }
}
